00001
00002
00003
00004
00005
00006 #ifndef _coarse_timer_h
00007 #define _coarse_timer_h
00008
00009 #include <map>
00010 #include <string>
00011 #include <vector>
00012
00013 #include <boost/serialization/export.hpp>
00014
00015
00016
00017 namespace gridpack{
00018 namespace utility{
00019
00020 class CoarseTimer {
00021 public:
00022
00023
00024
00025
00026 static CoarseTimer *instance();
00027
00028
00029
00030
00031
00032
00033
00034
00035 int createCategory(const std::string title);
00036
00037
00038
00039
00040
00041 void start(const int idx);
00042
00043
00044
00045
00046
00047 void stop(const int idx);
00048
00049
00050
00051
00052 void dump(void) const;
00053
00054
00055
00056
00057
00058 void dumpProfile(const int idx) const;
00059
00060
00061
00062
00063
00064 void dumpProfile(const std::string title);
00065
00066
00067
00068
00069
00070
00071 double currentTime();
00072
00073
00074
00075
00076
00077 void configTimer(bool flag);
00078
00079 protected:
00080
00081
00082
00083 CoarseTimer();
00084
00085
00086
00087
00088 ~CoarseTimer();
00089
00090 private:
00091
00092 std::map<std::string, int> p_title_map;
00093 std::vector<std::string> p_title;
00094 std::vector<double> p_start;
00095 std::vector<double> p_time;
00096 std::vector<int> p_istart;
00097 std::vector<int> p_istop;
00098
00099 static CoarseTimer *p_instance;
00100
00101 bool p_profile;
00102 };
00103
00104
00105 }
00106 }
00107
00108 BOOST_CLASS_EXPORT_KEY(gridpack::utility::CoarseTimer)
00109
00110 #endif // _coarse_timer_h